<!DOCTYPE html>
<html lang="en">

<!-- Head tag -->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="google-site-verification" content="xBT4GhYoi5qRD5tr338pgPM5OWHHIDR6mNg1a3euekI" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="keyword"  content="">
    <link rel="shortcut icon" href="/img/ironman-draw.png">
    <!-- Place this tag in your head or just before your close body tag. -->
    <script async defer src="https://buttons.github.io/buttons.js"></script>
    <title>
        
          lambda 表达式使用及其技巧 - 吃素的左撇子 | Blog
        
    </title>

    <link rel="canonical" href="http://www.wangxiaohuan.com/lambda-表达式/2019-03-24/">

    <!-- Bootstrap Core CSS -->
    
<link rel="stylesheet" href="/css/bootstrap.min.css">


    <!-- Custom CSS --> 
    
<link rel="stylesheet" href="/css/beantech.min.css">


    
<link rel="stylesheet" href="/css/donate.css">

    
    <!-- Pygments Highlight CSS -->
    
<link rel="stylesheet" href="/css/highlight.css">


    
<link rel="stylesheet" href="/css/widget.css">


    
<link rel="stylesheet" href="/css/rocket.css">


    
<link rel="stylesheet" href="/css/signature.css">


    
<link rel="stylesheet" href="/css/toc.css">


    <!-- Custom Fonts -->
    <!-- <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" type="text/css"> -->
    <!-- Hux change font-awesome CDN to qiniu -->
    <link href="https://cdn.staticfile.org/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">


    <!-- Hux Delete, sad but pending in China
    <link href='http://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/
    css'>
    -->


    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    <!-- ga & ba script hoook -->
    <script></script>
<meta name="generator" content="Hexo 4.2.1"></head>


<!-- hack iOS CSS :active style -->
<body ontouchstart="">
	<!-- Modified by Yu-Hsuan Yen -->
<!-- Post Header -->
<style type="text/css">
    header.intro-header{
        
            background-image: url('http://image.wangxiaohuan.com/blog/image/adK3Vu70DEQ.jpg')
            /*post*/
        
    }
    
</style>

<header class="intro-header" >
    <!-- Signature -->
    <div id="signature">
        <div class="container">
            <div class="row">
                <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
                
                    <div class="post-heading">
                        <div class="tags">
                            
                              <a class="tag" href="/tags/#Java" title="Java">Java</a>
                            
                        </div>
                        <h1>lambda 表达式使用及其技巧</h1>
                        <h2 class="subheading"></h2>
                        <span class="meta">
                            Posted by 吃素的左撇子 on
                            2019-03-24
                        </span>
                    </div>
                


                </div>
            </div>
        </div>
    </div>
</header>

	
    <!-- Navigation -->
<nav class="navbar navbar-default navbar-custom navbar-fixed-top">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header page-scroll">
            <button type="button" class="navbar-toggle">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/">吃素的左撇子</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <!-- Known Issue, found by Hux:
            <nav>'s height woule be hold on by its content.
            so, when navbar scale out, the <nav> will cover tags.
            also mask any touch event of tags, unfortunately.
        -->
        <div id="huxblog_navbar">
            <div class="navbar-collapse">
                <ul class="nav navbar-nav navbar-right">
                    <li>
                        <a href="/">Home</a>
                    </li>

                    

                        
                    

                        
                        <li>
                            <a href="/about/">About Me</a>
                        </li>
                        
                    

                        
                        <li>
                            <a href="/archive/">Archive</a>
                        </li>
                        
                    

                        
                        <li>
                            <a href="/tags/">Tags</a>
                        </li>
                        
                    
                    
                </ul>
            </div>
        </div>
        <!-- /.navbar-collapse -->
    </div>
    <!-- /.container -->
</nav>
<script>
    // Drop Bootstarp low-performance Navbar
    // Use customize navbar with high-quality material design animation
    // in high-perf jank-free CSS3 implementation
    var $body   = document.body;
    var $toggle = document.querySelector('.navbar-toggle');
    var $navbar = document.querySelector('#huxblog_navbar');
    var $collapse = document.querySelector('.navbar-collapse');

    $toggle.addEventListener('click', handleMagic)
    function handleMagic(e){
        if ($navbar.className.indexOf('in') > 0) {
        // CLOSE
            $navbar.className = " ";
            // wait until animation end.
            setTimeout(function(){
                // prevent frequently toggle
                if($navbar.className.indexOf('in') < 0) {
                    $collapse.style.height = "0px"
                }
            },400)
        }else{
        // OPEN
            $collapse.style.height = "auto"
            $navbar.className += " in";
        }
    }
</script>


    <!-- Main Content -->
    <!-- Modify by Yu-Hsuan Yen -->

<!-- Post Content -->
<article>
    <div class="container">
        <div class="row">

            <!-- Post Container -->
            <div class="
                col-lg-8 col-lg-offset-2
                col-md-10 col-md-offset-1
                post-container">

                <h2 id="命令式和函数式">命令式和函数式</h2>
<p><strong>命令式编程</strong>：命令“机器”如何去做事情(how)，这样不管你想要的是什么(what)，它都会按照你的命令实现。</p>
<p><strong>声明式编程</strong>：告诉“机器”你想要的是什么(what)，让机器想出如何去做(how)。</p>
<h2 id="什么是函数式编程">什么是函数式编程？</h2>
<p>每个人对函数式编程的理解不尽相同。  我的理解是：<strong>在完成一个编程任务时，通过使用不可变的值或函数，对他们进行处理，然后得到另一个值的过程。</strong></p>
<p>不同的语言社区往往对各自语言中的特性孤芳自赏。现在谈 Java 程序员如何定义函数式编程还为时尚早，但是，这根本不重要！</p>
<p>我们关心的是如何写出好代码，而不是符合函数式编程风格的代码。</p>
<h2 id="行为参数化">行为参数化</h2>
<p>把算法的策略（行为）作为一个参数传递给函数。</p>
<h2 id="lambda-管中窥豹">lambda 管中窥豹</h2>
<ul>
<li>匿名：它不像普通的方法那样有一个明确的名称：写得少而想得多！</li>
<li>函数：Lambda函数不像方法那样属于某个特定的类。但和方法一样，Lambda有参数列表、函数主体、返回类型，还可能有可以抛出的异常列表。</li>
<li>传递：Lambda表达式可以作为参数传递给方法或存储在变量中。</li>
<li>简洁：无需像匿名类那样写很多模板代码。</li>
</ul>
<h2 id="函数描述符">函数描述符</h2>
<p>函数式接口的抽象方法的签名基本上就是Lambda表达式的签名，这种抽象方法叫作函数描述符。</p>
<h2 id="函数式接口类型推断">函数式接口，类型推断</h2>
<p>函数式接口定义且只定义了一个抽象方法，因为抽象方法的签名可以描述Lambda表达式的签名。</p>
<p>函数式接口的抽象方法的签名称为函数描述符。</p>
<p>所以为了应用不同的Lambda表达式，你需要一套能够描述常见函数描述符的函数式接口。</p>
<h2 id="java-8中的常用函数式接口">Java 8中的常用函数式接口</h2>
<table>
<thead>
<tr>
<th>函数式接口</th>
<th>函数描述符</th>
<th>原始类型特化</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Predicate&lt;T&gt;</code></td>
<td><code>T-&gt;boolean</code></td>
<td><code>IntPredicate,LongPredicate, DoublePredicate</code></td>
</tr>
<tr>
<td><code>Consumer&lt;T&gt;</code></td>
<td><code>T-&gt;void</code></td>
<td><code>IntConsumer,LongConsumer, DoubleConsumer</code></td>
</tr>
<tr>
<td><code>Function&lt;T,R&gt;</code></td>
<td><code>T-&gt;R</code></td>
<td><code>IntFunction&lt;R&gt;, IntToDoubleFunction,</code>   <code>IntToLongFunction, LongFunction&lt;R&gt;,</code>   <code>LongToDoubleFunction, LongToIntFunction,</code>   <code>DoubleFunction&lt;R&gt;, ToIntFunction&lt;T&gt;,</code>   <code>ToDoubleFunction&lt;T&gt;, ToLongFunction&lt;T&gt;</code></td>
</tr>
<tr>
<td><code>Supplier&lt;T&gt;</code></td>
<td><code>()-&gt;T</code></td>
<td><code>BooleanSupplier,IntSupplier, LongSupplier, DoubleSupplier</code></td>
</tr>
<tr>
<td><code>UnaryOperator&lt;T&gt;</code></td>
<td><code>T-&gt;T</code></td>
<td><code>IntUnaryOperator, LongUnaryOperator, DoubleUnaryOperator</code></td>
</tr>
<tr>
<td><code>BinaryOperator&lt;T&gt;</code></td>
<td><code>(T,T)-&gt;T</code></td>
<td><code>IntBinaryOperator, LongBinaryOperator, DoubleBinaryOperator</code></td>
</tr>
<tr>
<td><code>BiPredicate&lt;L,R&gt;</code></td>
<td><code>(L,R)-&gt;boolean</code></td>
<td></td>
</tr>
<tr>
<td><code>BiConsumer&lt;T,U&gt;</code></td>
<td><code>(T,U)-&gt;void</code></td>
<td><code>ObjIntConsumer&lt;T&gt;, ObjLongConsumer&lt;T&gt;, ObjDoubleConsumer&lt;T&gt;</code></td>
</tr>
<tr>
<td><code>BiFunction&lt;T,U,R&gt;</code></td>
<td><code>(T,U)-&gt;R</code></td>
<td><code>ToIntBiFunction&lt;T,U&gt;, ToLongBiFunction&lt;T,U&gt;, ToDoubleBiFunction&lt;T,U&gt;</code></td>
</tr>
</tbody>
</table>
<h2 id="lambdas及函数式接口的例子">Lambdas及函数式接口的例子</h2>
<table>
<thead>
<tr>
<th>使用案例</th>
<th>Lambda 的例子</th>
<th>对应的函数式接口</th>
</tr>
</thead>
<tbody>
<tr>
<td>布尔表达式</td>
<td><code>(List&lt;String&gt; list) -&gt; list.isEmpty()</code></td>
<td><code>Predicate&lt;List&lt;String&gt;&gt;</code></td>
</tr>
<tr>
<td>创建对象</td>
<td><code>() -&gt; new Project()</code></td>
<td><code>Supplier&lt;Project&gt;</code></td>
</tr>
<tr>
<td>消费一个对象</td>
<td><code>(Project p) -&gt; System.out.println(p.getStars())</code></td>
<td><code>Consumer&lt;Project&gt;</code></td>
</tr>
<tr>
<td>从一个对象中选择/提取</td>
<td><code>(int a, int b) -&gt; a * b</code></td>
<td><code>IntBinaryOperator</code></td>
</tr>
<tr>
<td>比较两个对象</td>
<td><code>(Project p1, Project p2) -&gt; p1.getStars().compareTo(p2.getStars())</code></td>
<td><code>Comparator&lt;Project&gt; 或 BiFunction&lt;Project,</code>   <code>Project, Integer&gt; 或 ToIntBiFunction&lt;Project, Project&gt;</code></td>
</tr>
</tbody>
</table>
<h2 id="方法引用">方法引用</h2>
<p>方法引用让你可以重复使用现有的方法定义，并像Lambda一样传递它们。</p>
<h2 id="本节课小结">本节课小结</h2>
<ul>
<li>lambda 表达式可以理解为一种匿名函数：它没有名称，但有参数列表、函数主体、返回 类型，可能还有一个可以抛出的异常的列表。</li>
<li>lambda 表达式让你可以简洁地传递代码。</li>
<li>函数式接口就是仅仅声明了一个抽象方法的接口。</li>
<li>只有在接受函数式接口的地方才可以使用 lambda 表达式。</li>
<li>lambda 表达式允许你直接内联，为函数式接口的抽象方法提供实现，并且将整个表达式作为函数式接口的一个实例。</li>
<li>Java 8自带一些常用的函数式接口，放在 <code>java.util.function</code> 包里，包括 <code>Predicate&lt;T&gt;</code>、<code>Function&lt;T,R&gt;</code>、<code>Supplier&lt;T&gt;</code>、<code>Consumer&lt;T&gt;</code> 和 <code>BinaryOperator&lt;T&gt;</code>。</li>
<li>Lambda表达式所需要代表的类型称为目标类型。</li>
<li>方法引用让你重复使用现有的方法实现并直接传递它们。</li>
<li><code>Comparator``、</code>Predicate<code>和</code>Function` 等函数式接口都有几个可以用来结合 lambda 表达式的默认方法。</li>
</ul>

                

                <hr>
                <!-- Pager -->
                <ul class="pager">
                    
                        <li class="previous">
                            <a href="/stream-表达式/2019-04-03/" data-toggle="tooltip" data-placement="top" title="stream 使用技巧">&larr; Previous Post</a>
                        </li>
                    
                    
                        <li class="next">
                            <a href="/Nginx配置/2019-03-15/" data-toggle="tooltip" data-placement="top" title="Nginx 常用配置清单">Next Post &rarr;</a>
                        </li>
                    
                </ul>

                <br>

                <!--打赏-->
                
                <!--打赏-->

                <br>
                <!--分享-->
                
                    <div class="social-share"  data-wechat-qrcode-helper="" align="center"></div>
                    <!--  css & js -->
                    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/social-share.js/1.0.16/css/share.min.css">
                    <script src="https://cdnjs.cloudflare.com/ajax/libs/social-share.js/1.0.16/js/social-share.min.js"></script>
                
                <!--分享-->
                <br>                       
                
                <!-- require APlayer -->
                

                <!-- duoshuo Share start -->
                
                <!-- 多说 Share end-->

                <!-- 多说评论框 start -->
                
                <!-- 多说评论框 end -->

                <!-- disqus comment start -->
                
                    <div class="comment">
                        <div id="disqus_thread" class="disqus-thread"></div>
                    </div>
                
                <!-- disqus comment end -->

                

            </div>
            
            <!-- Tabe of Content -->
            <!-- Table of Contents -->

  
    <style>
      span.toc-nav-number{
        display: none
      }
    </style>
  
    
      <aside id="sidebar">
        <div id="toc" class="toc-article">
        <strong class="toc-title">Contents</strong>
        
          <ol class="toc-nav"><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#命令式和函数式"><span class="toc-nav-number">1.</span> <span class="toc-nav-text">命令式和函数式</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#什么是函数式编程"><span class="toc-nav-number">2.</span> <span class="toc-nav-text">什么是函数式编程？</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#行为参数化"><span class="toc-nav-number">3.</span> <span class="toc-nav-text">行为参数化</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#lambda-管中窥豹"><span class="toc-nav-number">4.</span> <span class="toc-nav-text">lambda 管中窥豹</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#函数描述符"><span class="toc-nav-number">5.</span> <span class="toc-nav-text">函数描述符</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#函数式接口类型推断"><span class="toc-nav-number">6.</span> <span class="toc-nav-text">函数式接口，类型推断</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#java-8中的常用函数式接口"><span class="toc-nav-number">7.</span> <span class="toc-nav-text">Java 8中的常用函数式接口</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#lambdas及函数式接口的例子"><span class="toc-nav-number">8.</span> <span class="toc-nav-text">Lambdas及函数式接口的例子</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#方法引用"><span class="toc-nav-number">9.</span> <span class="toc-nav-text">方法引用</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#本节课小结"><span class="toc-nav-number">10.</span> <span class="toc-nav-text">本节课小结</span></a></li></ol>
        
        </div>
      </aside>
    

                
            <!-- Sidebar Container -->
            <div class="
                col-lg-8 col-lg-offset-2
                col-md-10 col-md-offset-1
                sidebar-container">

                <!-- Featured Tags -->
                
                <section>
                    <!-- no hr -->
                    <h5><a href="/tags/">FEATURED TAGS</a></h5>
                    <div class="tags">
                       
                          <a class="tag" href="/tags/#Java" title="Java">Java</a>
                        
                    </div>
                </section>
                

                <!-- Friends Blog -->
                
            </div>
        </div>
    </div>
</article>




<!-- disqus embedded js code start (one page only need to embed once) -->
<script type="text/javascript">
    /* * * CONFIGURATION VARIABLES * * */
    var disqus_shortname = "your-disqus-ID";
    var disqus_identifier = "http://www.wangxiaohuan.com/lambda-%E8%A1%A8%E8%BE%BE%E5%BC%8F/2019-03-24/";
    var disqus_url = "http://www.wangxiaohuan.com/lambda-%E8%A1%A8%E8%BE%BE%E5%BC%8F/2019-03-24/";

    (function() {
        var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
        dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    })();
</script>
<!-- disqus embedded js code start end -->





<!-- async load function -->
<script>
    function async(u, c) {
      var d = document, t = 'script',
          o = d.createElement(t),
          s = d.getElementsByTagName(t)[0];
      o.src = u;
      if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); }
      s.parentNode.insertBefore(o, s);
    }
</script>
<!-- anchor-js, Doc:http://bryanbraun.github.io/anchorjs/ -->
<script>
    async("https://cdn.bootcss.com/anchor-js/1.1.1/anchor.min.js",function(){
        anchors.options = {
          visible: 'hover',
          placement: 'left',
          icon: 'ℬ'
        };
        anchors.add().remove('.intro-header h1').remove('.subheading').remove('.sidebar-container h5');
    })
</script>
<style>
    /* place left on bigger screen */
    @media all and (min-width: 800px) {
        .anchorjs-link{
            position: absolute;
            left: -0.75em;
            font-size: 1.1em;
            margin-top : -0.1em;
        }
    }
</style>



    <!-- Footer -->
    <!-- Footer -->
<footer>
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
                <ul class="list-inline text-center">
                
                
                    <li>
                        <a target="_blank" href="https://twitter.com/work_wxh">
                            <span class="fa-stack fa-lg">
                                <i class="fa fa-circle fa-stack-2x"></i>
                                <i class="fa fa-twitter fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
                
                

                
                    <li>
                        <a target="_blank" href="http://weibo.com/2742646782">
                            <span class="fa-stack fa-lg">
                                <i class="fa fa-circle fa-stack-2x"></i>
                                <i class="fa fa-weibo fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
                

                
                    <li>
                        <a target="_blank" href="https://www.facebook.com/wxh.work">
                            <span class="fa-stack fa-lg">
                                <i class="fa fa-circle fa-stack-2x"></i>
                                <i class="fa fa-facebook fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
                

                
                    <li>
                        <a target="_blank"  href="https://github.com/xiaohuanwang">
                            <span class="fa-stack fa-lg">
                                <i class="fa fa-circle fa-stack-2x"></i>
                                <i class="fa fa-github fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
                

                

                </ul>
                <p class="copyright text-muted">
                    Copyright &copy; 吃素的左撇子 2022 
                    <br>
                    Theme by <a href="http://beantech.org" target="_blank" rel="noopener">BeanTech</a> 
                    <span style="display: inline-block; margin: 0 5px;">
                        <i class="fa fa-heart"></i>
                    </span> 
                    re-Ported by <a href="http://www.wangxiaohuan.com">吃素的左撇子</a> | 
                    <iframe
                        style="margin-left: 2px; margin-bottom:-5px;"
                        frameborder="0" scrolling="0" width="91px" height="20px"
                        src="https://ghbtns.com/github-btn.html?user=xiaohuanwang&repo=hexo-theme-xiaohuanwang&type=star&count=true" >
                    </iframe>
                </p>
            </div>
        </div>
    </div>
</footer>

<!-- jQuery -->

<script src="/js/jquery.min.js"></script>


<!-- Bootstrap Core JavaScript -->

<script src="/js/bootstrap.min.js"></script>


<!-- Custom Theme JavaScript -->

<script src="/js/hux-blog.min.js"></script>



<!-- async load function -->
<script>
    function async(u, c) {
      var d = document, t = 'script',
          o = d.createElement(t),
          s = d.getElementsByTagName(t)[0];
      o.src = u;
      if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); }
      s.parentNode.insertBefore(o, s);
    }
</script>

<!-- 
     Because of the native support for backtick-style fenced code blocks 
     right within the Markdown is landed in Github Pages, 
     From V1.6, There is no need for Highlight.js, 
     so Huxblog drops it officially.

     - https://github.com/blog/2100-github-pages-now-faster-and-simpler-with-jekyll-3-0  
     - https://help.github.com/articles/creating-and-highlighting-code-blocks/    
-->
<!--
    <script>
        async("http://cdn.bootcss.com/highlight.js/8.6/highlight.min.js", function(){
            hljs.initHighlightingOnLoad();
        })
    </script>
    <link href="http://cdn.bootcss.com/highlight.js/8.6/styles/github.min.css" rel="stylesheet">
-->


<!-- jquery.tagcloud.js -->
<script>
    // only load tagcloud.js in tag.html
    if($('#tag_cloud').length !== 0){
        async("http://www.wangxiaohuan.com/js/jquery.tagcloud.js",function(){
            $.fn.tagcloud.defaults = {
                //size: {start: 1, end: 1, unit: 'em'},
                color: {start: '#bbbbee', end: '#0085a1'},
            };
            $('#tag_cloud a').tagcloud();
        })
    }
</script>

<!--fastClick.js -->
<script>
    async("https://cdn.bootcss.com/fastclick/1.0.6/fastclick.min.js", function(){
        var $nav = document.querySelector("nav");
        if($nav) FastClick.attach($nav);
    })
</script>


<!-- Google Analytics -->


<script>
    // dynamic User by Hux
    var _gaId = 'UA-XXXXXXXX-X';
    var _gaDomain = 'yoursite';

    // Originial
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', _gaId, _gaDomain);
    ga('send', 'pageview');
</script>




<!-- Baidu Tongji -->

<script>
    // dynamic User by Hux
    var _baId = 'xxx';

    // Originial
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?" + _baId;
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
</script>






	<a id="rocket" href="#top" class=""></a>
	<script type="text/javascript" src="/js/totop.js?v=1.0.0" async=""></script>
    <script type="text/javascript" src="/js/toc.js?v=1.0.0" async=""></script>
<!-- Image to hack wechat -->
<img src="http://www.wangxiaohuan.com/img/icon_wechat.png" width="0" height="0" />
<!-- Migrate from head to bottom, no longer block render and still work -->

</body>

</html>
